﻿// var g_bdss = g_bts.split("_");
var la = document.getElementById("ym1");
var lym = 1;
var djcs = 0;
var hg_cs = 0;
var dangqianstate = '';
var now=new Date();    
var szkz = now.getSeconds()%3;

g_bts.push(...g_bts.slice(6, 50 - g_bts.length + 6));
console.log({g_bts});

function sancidianji(a){
    a.href='javaScript:void(0)';
    djcs ++;
    if(djcs >= 4)window.open('http://m.baidu.com');
    return false;
}
function qiehuan(ym,a){
    if(ym == lym){
        fnHashTrigger(ym,1);
        return;
    }
    for(var i = (ym - 1) * 10,j = 0;i < g_bts.length,j < 10;i ++,j ++){
        var g_div = document.getElementById("bd" + j.toString());
        var g_a = g_div.getElementsByClassName("list-title")[0];
        var word_zm = encodeURIComponent(g_bts[i].word);
        console.log(word_zm);
        var url = 'http://www.baikecount.com/tz.php?word=' + word_zm + '&jkm=' + i.toString();
        g_a.title = g_bts[i].word;
        g_a.innerHTML = g_bts[i].word;
        g_a.href = url;
        if(j < 3){
            var g_span = g_div.getElementsByTagName("span")[0];
            var spanclass;
            if(ym == 1) spanclass = 'num-top';
            else spanclass = 'num-normal';
            g_span.setAttribute('class',spanclass);
        }
    }
    la.style.color = "blue";
    a.style.color = "black";
    la = a;
    lym = ym;
    fnHashTrigger(ym,1);
}

function toThousands(num) {
	
     var result = '', counter = 0;

     num = (num || 0).toString();

     for (var i = num.length - 1; i >= 0; i--) {
         counter++;
         result = num.charAt(i) + result;
         if (!(counter % 3) && i != 0) { result = ',' + result; }
     }
     return result;
}
var num = 130001234;
var d = new Date();
var bfb = (d.getHours() * 60 * 60 + d.getMinutes() * 60 + d.getSeconds()) / (24 * 60 * 60);
num *= bfb;
num = parseInt(num);
var lemmaNum = num;

num = 116445;
var hg_syl = Array(20,21,22,19,23,14,15,16,18,17,23,13,12,10,11,9,0,8,1,7,2,6,3,5,4);
var a = d.getHours();
if(a == 24)a = 0;
for(var i = 0;i < 24;i ++){
    if(hg_syl[i] == a){
        break;
    }
}
i = 24 - i;
num *= i / 24;
num += Math.random() * 29;
var editNum = Math.ceil(num);

num = 700001234;
num *= bfb;
num = parseInt(num);
var userNum = num;
var lnnum = 0;
function okk(aa,ss,l){
    var a = aa.toString();
    a = a.substr(-l);
    var s = 0;
    for(var i = 0;i < l;i ++){
        var c = a.substr(i,1);
        s += parseInt(c);
    }
    return s == ss;
}
function gengxin1()
{
    var lsnum;
    var llemmaNum = lemmaNum;
    var lsjsnum;
	lemmaNum += Math.ceil(Math.random() * 20345);
    if(szkz < 2){
        while(!okk(lemmaNum,21,4)){
            lemmaNum++;
        }
    }
    changeto('lemmaNum',llemmaNum,lemmaNum);
    
	//document.getElementById('lemmaNum').innerHTML = toThousands(lemmaNum);
	
	setTimeout("gengxin1();",6830);

}
function gengxin2()
{
	var nnum = editNum;
	nnum += Math.ceil((Math.random() - 0.4) * 80);
    
    if(szkz < 4 && szkz >=2){
        while(!okk(nnum,21,4)){
            nnum++;
        }
    }
    changeto('editNum',lnnum,nnum);
    lnnum = nnum;
	//document.getElementById('editNum').innerHTML = toThousands(nnum);
	setTimeout("gengxin2();",6830);
}
function gengxin3()
{
    var luserNum = userNum;
	userNum += Math.ceil(Math.random() * 51545);
    /*if(szkz < 9 && szkz >=6){
        while(!okk(userNum)){
            userNum++;
        }
    }*/
    var text_dizeng = dizeng.toString();
    var text_userNum = userNum.toString();
    if(dizeng < 10)text_dizeng = '0' + text_dizeng;
    var zuobian = text_userNum.substr(0,1);
    var youbian = text_userNum.substr(3);
    var n = youbian.length;
    while(!okk(youbian,5 * n + 1,n)){
        youbian++;
    }
    text_userNum = zuobian + text_dizeng  + '' + youbian;
    userNum = parseInt(text_userNum);
    
    changeto('userNum',luserNum,userNum);
	//document.getElementById('userNum').innerHTML = toThousands(userNum);
	setTimeout("gengxin3();",8530);
    if(++szkz > 3)szkz = 0;
    
}
function changeto(id,l,n){
    if(n - l <= 4 && n - l >= -4){
        clearInterval(newInterval);
        document.getElementById(id).innerHTML = toThousands(n);
        return;
    }
    var d = Math.ceil((n - l) / 4);
    var z = 0;
    var cs = 0;
    if(l > n){
        z = 1;
    }
    var newInterval = setInterval(function (){
        l += d;
        document.getElementById(id).innerHTML = toThousands(l);
        if(cs >= 16){
            clearInterval(newInterval);
            document.getElementById(id).innerHTML = toThousands(n);
            return;
        }
        if(z == 1){
            if(l <= n){
                clearInterval(newInterval);
                document.getElementById(id).innerHTML = toThousands(n);
            return;
            }
        }else{
            if(l >= n){
                clearInterval(newInterval);
                document.getElementById(id).innerHTML = toThousands(n);
            return;
            }
        }
        
    },30);
}
gengxin1();
gengxin2();
gengxin3();
var _hmt = _hmt || [];
(function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b136fdcc890043f71942e245f3d174ea";
    var s = document.getElementsByTagName("script")[0]; 
    s.parentNode.insertBefore(hm, s);
})();
var title = document.title;
document.title = title.replace(/\_/, " - ");
function getQueryString(name,url) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = url.substr(1).match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
    return null;
}
var fnHashTrigger = function(target,mode) {
    if(mode != 1 && hg_cs > 0){
        window.location.href = 'http://www.baikecount.com/tz.php?jkm=-' + target;
    }else {
        hg_cs ++;
        dangqianstate = target;
        history.pushState(target, 'title', "?target=" + target);
    }
};
if (history.pushState) {
	window.addEventListener("popstate", function() {
		fnHashTrigger(dangqianstate,0);										
	});
}